package com.bit.demo.mybatisdemo.service;

import com.bit.demo.mybatisdemo.mapper.UserInfoMapper;
import com.bit.demo.mybatisdemo.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    public List<UserInfo> getAllUser() {
        return userInfoMapper.selectAll();
    }

    public UserInfo getUserById(Integer id) {
        return userInfoMapper.selectById(id);
    }

    public UserInfo login(String userName, String password) {
        List<UserInfo> userInfos = userInfoMapper.selectByNameAndPassword4(userName, password);
        if(userInfos!=null&&userInfos.size()>=1){
            return userInfos.get(0);
        }
        return null;
    }
}
